package com.fc.mall.portal.controller;

import com.fc.mall.base.object.Result;
import com.fc.mall.portal.service.GroupProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by sunny on 2019/8/16.
 */
@RestController
@RequestMapping("/group-buy")
public class PmsProductGroupByController {

    @Autowired
    private GroupProductService groupProductService;

    @GetMapping("list")
    public Result list(
            @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
            @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum)
    {
        return Result.success(groupProductService.listGroupProduct(pageNum, pageSize));
    }


    @GetMapping("{id}")
    public Result getGroupBuyProductInfo(@PathVariable Long id)
    {
        return Result.success(groupProductService.getGroupProductById(id));
    }

    @GetMapping("promotion/{promotionId}")
    public Result listByPromotion(@PathVariable("promotionId") Long promotionId)
    {
        return Result.success(groupProductService.getGroupProductByPromotion(promotionId));
    }

}
